﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Himp.Platform.Migrations
{
    /// <inheritdoc />
    public partial class modify_data_table : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "MainStdFormDict");

            migrationBuilder.DropTable(
                name: "MainStdTableRestrRule");

            migrationBuilder.DropTable(
                name: "MainStdViewValueDict");

            migrationBuilder.DropTable(
                name: "MainStdTableColumnDict");

            migrationBuilder.DropTable(
                name: "MainStdViewDict");

            migrationBuilder.DropTable(
                name: "MainStdTableDict");

            migrationBuilder.DropTable(
                name: "MainStdViewContainerDict");

            migrationBuilder.DropTable(
                name: "MainStdApiDict");

            migrationBuilder.CreateTable(
                name: "MainDataFormDict",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    ProductTopicId = table.Column<Guid>(type: "uuid", nullable: false),
                    FormName = table.Column<string>(type: "text", nullable: false),
                    Schema = table.Column<string>(type: "text", nullable: false),
                    Layout = table.Column<string>(type: "text", nullable: true),
                    Mode = table.Column<string>(type: "text", nullable: true),
                    DefaultFlag = table.Column<bool>(type: "boolean", nullable: false),
                    OpenApiConfigId = table.Column<Guid>(type: "uuid", nullable: true),
                    Ver = table.Column<int>(type: "integer", nullable: false),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true),
                    ExtraProperties = table.Column<string>(type: "text", nullable: false),
                    ConcurrencyStamp = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: false),
                    CreationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
                    CreatorId = table.Column<Guid>(type: "uuid", nullable: true),
                    LastModificationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
                    LastModifierId = table.Column<Guid>(type: "uuid", nullable: true),
                    IsDeleted = table.Column<bool>(type: "boolean", nullable: false, defaultValue: false),
                    DeleterId = table.Column<Guid>(type: "uuid", nullable: true),
                    DeletionTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MainDataFormDict", x => x.Id);
                    table.ForeignKey(
                        name: "FK_MainDataFormDict_MainProductTopic_ProductTopicId",
                        column: x => x.ProductTopicId,
                        principalTable: "MainProductTopic",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "MainOpenApiDict",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    ApiDictName = table.Column<string>(type: "text", nullable: false),
                    TopicDictId = table.Column<Guid>(type: "uuid", nullable: false),
                    InfNo = table.Column<string>(type: "text", nullable: false),
                    SignType = table.Column<string>(type: "text", nullable: true),
                    InfVerno = table.Column<string>(type: "text", nullable: false),
                    SrtNo = table.Column<int>(type: "integer", nullable: false),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true),
                    ExtraProperties = table.Column<string>(type: "text", nullable: false),
                    ConcurrencyStamp = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: false),
                    CreationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
                    CreatorId = table.Column<Guid>(type: "uuid", nullable: true),
                    LastModificationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
                    LastModifierId = table.Column<Guid>(type: "uuid", nullable: true),
                    IsDeleted = table.Column<bool>(type: "boolean", nullable: false, defaultValue: false),
                    DeleterId = table.Column<Guid>(type: "uuid", nullable: true),
                    DeletionTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MainOpenApiDict", x => x.Id);
                    table.ForeignKey(
                        name: "FK_MainOpenApiDict_MainProductTopic_TopicDictId",
                        column: x => x.TopicDictId,
                        principalTable: "MainProductTopic",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "MainDataTableDict",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    DataTableCodg = table.Column<string>(type: "text", nullable: false),
                    DataTableName = table.Column<string>(type: "text", nullable: false),
                    TableTemplateType = table.Column<int>(type: "integer", nullable: false),
                    Exp = table.Column<string>(type: "text", nullable: true),
                    DefaultFlag = table.Column<bool>(type: "boolean", nullable: false),
                    Ver = table.Column<int>(type: "integer", nullable: false),
                    OpenApiDictId = table.Column<Guid>(type: "uuid", nullable: true),
                    ProductTopicId = table.Column<Guid>(type: "uuid", nullable: false),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true),
                    ExtraProperties = table.Column<string>(type: "text", nullable: false),
                    ConcurrencyStamp = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: false),
                    CreationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
                    CreatorId = table.Column<Guid>(type: "uuid", nullable: true),
                    LastModificationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
                    LastModifierId = table.Column<Guid>(type: "uuid", nullable: true),
                    IsDeleted = table.Column<bool>(type: "boolean", nullable: false, defaultValue: false),
                    DeleterId = table.Column<Guid>(type: "uuid", nullable: true),
                    DeletionTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MainDataTableDict", x => x.Id);
                    table.ForeignKey(
                        name: "FK_MainDataTableDict_MainOpenApiDict_OpenApiDictId",
                        column: x => x.OpenApiDictId,
                        principalTable: "MainOpenApiDict",
                        principalColumn: "Id");
                    table.ForeignKey(
                        name: "FK_MainDataTableDict_MainProductTopic_ProductTopicId",
                        column: x => x.ProductTopicId,
                        principalTable: "MainProductTopic",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "MainDataViewContainerDict",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    ProductTopicId = table.Column<Guid>(type: "uuid", nullable: false),
                    ViewContainerName = table.Column<string>(type: "text", nullable: false),
                    Exp = table.Column<string>(type: "text", nullable: true),
                    ViewContainerTemplateType = table.Column<int>(type: "integer", nullable: false),
                    Size = table.Column<string>(type: "text", nullable: true),
                    Layout = table.Column<string>(type: "text", nullable: true),
                    Gutter = table.Column<int>(type: "integer", nullable: false),
                    LabelWidth = table.Column<int>(type: "integer", nullable: false),
                    Title = table.Column<string>(type: "text", nullable: true),
                    NoColon = table.Column<bool>(type: "boolean", nullable: false),
                    Bordered = table.Column<bool>(type: "boolean", nullable: false),
                    OpenApiDictId = table.Column<Guid>(type: "uuid", nullable: true),
                    DefaultFlag = table.Column<bool>(type: "boolean", nullable: false),
                    Ver = table.Column<int>(type: "integer", nullable: false),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true),
                    ExtraProperties = table.Column<string>(type: "text", nullable: false),
                    ConcurrencyStamp = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: false),
                    CreationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
                    CreatorId = table.Column<Guid>(type: "uuid", nullable: true),
                    LastModificationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
                    LastModifierId = table.Column<Guid>(type: "uuid", nullable: true),
                    IsDeleted = table.Column<bool>(type: "boolean", nullable: false, defaultValue: false),
                    DeleterId = table.Column<Guid>(type: "uuid", nullable: true),
                    DeletionTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MainDataViewContainerDict", x => x.Id);
                    table.ForeignKey(
                        name: "FK_MainDataViewContainerDict_MainOpenApiDict_OpenApiDictId",
                        column: x => x.OpenApiDictId,
                        principalTable: "MainOpenApiDict",
                        principalColumn: "Id");
                    table.ForeignKey(
                        name: "FK_MainDataViewContainerDict_MainProductTopic_ProductTopicId",
                        column: x => x.ProductTopicId,
                        principalTable: "MainProductTopic",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "MainDataTableColumn",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    DataTableDictId = table.Column<Guid>(type: "uuid", nullable: false),
                    HeaderName = table.Column<string>(type: "text", nullable: false),
                    Field = table.Column<string>(type: "text", nullable: false),
                    Type = table.Column<string>(type: "text", nullable: false),
                    Srtno = table.Column<int>(type: "integer", nullable: false),
                    ColumnWidthType = table.Column<int>(type: "integer", nullable: false),
                    WidthValue = table.Column<double>(type: "double precision", nullable: false),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MainDataTableColumn", x => x.Id);
                    table.ForeignKey(
                        name: "FK_MainDataTableColumn_MainDataTableDict_DataTableDictId",
                        column: x => x.DataTableDictId,
                        principalTable: "MainDataTableDict",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "MainDataViewDict",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    Col = table.Column<int>(type: "integer", nullable: false),
                    Label = table.Column<string>(type: "text", nullable: false),
                    Unit = table.Column<string>(type: "text", nullable: false),
                    Type = table.Column<string>(type: "text", nullable: false),
                    Optional = table.Column<string>(type: "text", nullable: false),
                    OptionalHelp = table.Column<string>(type: "text", nullable: false),
                    OptionalHelpColor = table.Column<string>(type: "text", nullable: false),
                    NoColon = table.Column<bool>(type: "boolean", nullable: false),
                    HideLabel = table.Column<bool>(type: "boolean", nullable: false),
                    DataViewContainerDictId = table.Column<Guid>(type: "uuid", nullable: false),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true),
                    CreationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
                    CreatorId = table.Column<Guid>(type: "uuid", nullable: true),
                    LastModificationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
                    LastModifierId = table.Column<Guid>(type: "uuid", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MainDataViewDict", x => x.Id);
                    table.ForeignKey(
                        name: "FK_MainDataViewDict_MainDataViewContainerDict_DataViewContaine~",
                        column: x => x.DataViewContainerDictId,
                        principalTable: "MainDataViewContainerDict",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "MainDataTableRestrRule",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    DataTableDictId = table.Column<Guid>(type: "uuid", nullable: false),
                    DataTableColumnId = table.Column<Guid>(type: "uuid", nullable: false),
                    TableRestrRuleProvider = table.Column<int>(type: "integer", nullable: false),
                    RestrRuleValue = table.Column<string>(type: "text", nullable: true),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true),
                    CreationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
                    CreatorId = table.Column<Guid>(type: "uuid", nullable: true),
                    LastModificationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
                    LastModifierId = table.Column<Guid>(type: "uuid", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MainDataTableRestrRule", x => x.Id);
                    table.ForeignKey(
                        name: "FK_MainDataTableRestrRule_MainDataTableColumn_DataTableColumnId",
                        column: x => x.DataTableColumnId,
                        principalTable: "MainDataTableColumn",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_MainDataTableRestrRule_MainDataTableDict_DataTableDictId",
                        column: x => x.DataTableDictId,
                        principalTable: "MainDataTableDict",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "MainDataViewValueDict",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    Prefix = table.Column<string>(type: "text", nullable: false),
                    Unit = table.Column<string>(type: "text", nullable: false),
                    Tooltip = table.Column<string>(type: "text", nullable: false),
                    Size = table.Column<string>(type: "text", nullable: false),
                    DataViewDictId = table.Column<Guid>(type: "uuid", nullable: false),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true),
                    CreationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
                    CreatorId = table.Column<Guid>(type: "uuid", nullable: true),
                    LastModificationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
                    LastModifierId = table.Column<Guid>(type: "uuid", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MainDataViewValueDict", x => x.Id);
                    table.ForeignKey(
                        name: "FK_MainDataViewValueDict_MainDataViewDict_DataViewDictId",
                        column: x => x.DataViewDictId,
                        principalTable: "MainDataViewDict",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_MainDataFormDict_ProductTopicId",
                table: "MainDataFormDict",
                column: "ProductTopicId");

            migrationBuilder.CreateIndex(
                name: "IX_MainDataTableColumn_DataTableDictId",
                table: "MainDataTableColumn",
                column: "DataTableDictId");

            migrationBuilder.CreateIndex(
                name: "IX_MainDataTableDict_OpenApiDictId",
                table: "MainDataTableDict",
                column: "OpenApiDictId");

            migrationBuilder.CreateIndex(
                name: "IX_MainDataTableDict_ProductTopicId",
                table: "MainDataTableDict",
                column: "ProductTopicId");

            migrationBuilder.CreateIndex(
                name: "IX_MainDataTableRestrRule_DataTableColumnId",
                table: "MainDataTableRestrRule",
                column: "DataTableColumnId");

            migrationBuilder.CreateIndex(
                name: "IX_MainDataTableRestrRule_DataTableDictId",
                table: "MainDataTableRestrRule",
                column: "DataTableDictId");

            migrationBuilder.CreateIndex(
                name: "IX_MainDataViewContainerDict_OpenApiDictId",
                table: "MainDataViewContainerDict",
                column: "OpenApiDictId");

            migrationBuilder.CreateIndex(
                name: "IX_MainDataViewContainerDict_ProductTopicId",
                table: "MainDataViewContainerDict",
                column: "ProductTopicId");

            migrationBuilder.CreateIndex(
                name: "IX_MainDataViewDict_DataViewContainerDictId",
                table: "MainDataViewDict",
                column: "DataViewContainerDictId");

            migrationBuilder.CreateIndex(
                name: "IX_MainDataViewValueDict_DataViewDictId",
                table: "MainDataViewValueDict",
                column: "DataViewDictId");

            migrationBuilder.CreateIndex(
                name: "IX_MainOpenApiDict_TopicDictId",
                table: "MainOpenApiDict",
                column: "TopicDictId");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "MainDataFormDict");

            migrationBuilder.DropTable(
                name: "MainDataTableRestrRule");

            migrationBuilder.DropTable(
                name: "MainDataViewValueDict");

            migrationBuilder.DropTable(
                name: "MainDataTableColumn");

            migrationBuilder.DropTable(
                name: "MainDataViewDict");

            migrationBuilder.DropTable(
                name: "MainDataTableDict");

            migrationBuilder.DropTable(
                name: "MainDataViewContainerDict");

            migrationBuilder.DropTable(
                name: "MainOpenApiDict");

            migrationBuilder.CreateTable(
                name: "MainStdApiDict",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    TopicDictId = table.Column<Guid>(type: "uuid", nullable: false),
                    ApiDictName = table.Column<string>(type: "text", nullable: false),
                    ConcurrencyStamp = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: false),
                    CreationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
                    CreatorId = table.Column<Guid>(type: "uuid", nullable: true),
                    DeleterId = table.Column<Guid>(type: "uuid", nullable: true),
                    DeletionTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
                    ExtraProperties = table.Column<string>(type: "text", nullable: false),
                    InfNo = table.Column<string>(type: "text", nullable: false),
                    InfVerno = table.Column<string>(type: "text", nullable: false),
                    IsDeleted = table.Column<bool>(type: "boolean", nullable: false, defaultValue: false),
                    LastModificationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
                    LastModifierId = table.Column<Guid>(type: "uuid", nullable: true),
                    SignType = table.Column<string>(type: "text", nullable: true),
                    SrtNo = table.Column<int>(type: "integer", nullable: false),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MainStdApiDict", x => x.Id);
                    table.ForeignKey(
                        name: "FK_MainStdApiDict_MainProductTopic_TopicDictId",
                        column: x => x.TopicDictId,
                        principalTable: "MainProductTopic",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "MainStdFormDict",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    ProductTopicId = table.Column<Guid>(type: "uuid", nullable: false),
                    ConcurrencyStamp = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: false),
                    CreationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
                    CreatorId = table.Column<Guid>(type: "uuid", nullable: true),
                    DefaultFlag = table.Column<bool>(type: "boolean", nullable: false),
                    DeleterId = table.Column<Guid>(type: "uuid", nullable: true),
                    DeletionTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
                    ExtraProperties = table.Column<string>(type: "text", nullable: false),
                    FormName = table.Column<string>(type: "text", nullable: false),
                    IsDeleted = table.Column<bool>(type: "boolean", nullable: false, defaultValue: false),
                    LastModificationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
                    LastModifierId = table.Column<Guid>(type: "uuid", nullable: true),
                    Layout = table.Column<string>(type: "text", nullable: true),
                    Mode = table.Column<string>(type: "text", nullable: true),
                    OpenApiConfigId = table.Column<Guid>(type: "uuid", nullable: true),
                    Schema = table.Column<string>(type: "text", nullable: false),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true),
                    Ver = table.Column<int>(type: "integer", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MainStdFormDict", x => x.Id);
                    table.ForeignKey(
                        name: "FK_MainStdFormDict_MainProductTopic_ProductTopicId",
                        column: x => x.ProductTopicId,
                        principalTable: "MainProductTopic",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "MainStdTableDict",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    StdApiConfigId = table.Column<Guid>(type: "uuid", nullable: true),
                    TopicDictId = table.Column<Guid>(type: "uuid", nullable: false),
                    ConcurrencyStamp = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: false),
                    CreationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
                    CreatorId = table.Column<Guid>(type: "uuid", nullable: true),
                    DefaultFlag = table.Column<bool>(type: "boolean", nullable: false),
                    DeleterId = table.Column<Guid>(type: "uuid", nullable: true),
                    DeletionTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
                    Exp = table.Column<string>(type: "text", nullable: true),
                    ExtraProperties = table.Column<string>(type: "text", nullable: false),
                    IsDeleted = table.Column<bool>(type: "boolean", nullable: false, defaultValue: false),
                    LastModificationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
                    LastModifierId = table.Column<Guid>(type: "uuid", nullable: true),
                    StdTableCodg = table.Column<string>(type: "text", nullable: false),
                    StdTableName = table.Column<string>(type: "text", nullable: false),
                    TableTemplateType = table.Column<int>(type: "integer", nullable: false),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true),
                    Ver = table.Column<int>(type: "integer", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MainStdTableDict", x => x.Id);
                    table.ForeignKey(
                        name: "FK_MainStdTableDict_MainProductTopic_TopicDictId",
                        column: x => x.TopicDictId,
                        principalTable: "MainProductTopic",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_MainStdTableDict_MainStdApiDict_StdApiConfigId",
                        column: x => x.StdApiConfigId,
                        principalTable: "MainStdApiDict",
                        principalColumn: "Id");
                });

            migrationBuilder.CreateTable(
                name: "MainStdViewContainerDict",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    StdApiConfigId = table.Column<Guid>(type: "uuid", nullable: true),
                    TopicDictId = table.Column<Guid>(type: "uuid", nullable: false),
                    Bordered = table.Column<bool>(type: "boolean", nullable: false),
                    CreationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
                    CreatorId = table.Column<Guid>(type: "uuid", nullable: true),
                    DefaultFlag = table.Column<bool>(type: "boolean", nullable: false),
                    Exp = table.Column<string>(type: "text", nullable: true),
                    Gutter = table.Column<int>(type: "integer", nullable: false),
                    LabelWidth = table.Column<int>(type: "integer", nullable: false),
                    LastModificationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
                    LastModifierId = table.Column<Guid>(type: "uuid", nullable: true),
                    Layout = table.Column<string>(type: "text", nullable: true),
                    NoColon = table.Column<bool>(type: "boolean", nullable: false),
                    Size = table.Column<string>(type: "text", nullable: true),
                    StdViewContainerName = table.Column<string>(type: "text", nullable: false),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true),
                    Title = table.Column<string>(type: "text", nullable: true),
                    Ver = table.Column<int>(type: "integer", nullable: false),
                    ViewContainerTemplateType = table.Column<int>(type: "integer", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MainStdViewContainerDict", x => x.Id);
                    table.ForeignKey(
                        name: "FK_MainStdViewContainerDict_MainProductTopic_TopicDictId",
                        column: x => x.TopicDictId,
                        principalTable: "MainProductTopic",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_MainStdViewContainerDict_MainStdApiDict_StdApiConfigId",
                        column: x => x.StdApiConfigId,
                        principalTable: "MainStdApiDict",
                        principalColumn: "Id");
                });

            migrationBuilder.CreateTable(
                name: "MainStdTableColumnDict",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    StdTableDictId = table.Column<Guid>(type: "uuid", nullable: false),
                    ColumnWidthType = table.Column<int>(type: "integer", nullable: false),
                    Field = table.Column<string>(type: "text", nullable: false),
                    HeaderName = table.Column<string>(type: "text", nullable: false),
                    Srtno = table.Column<int>(type: "integer", nullable: false),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true),
                    Type = table.Column<string>(type: "text", nullable: false),
                    WidthValue = table.Column<double>(type: "double precision", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MainStdTableColumnDict", x => x.Id);
                    table.ForeignKey(
                        name: "FK_MainStdTableColumnDict_MainStdTableDict_StdTableDictId",
                        column: x => x.StdTableDictId,
                        principalTable: "MainStdTableDict",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "MainStdViewDict",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    Col = table.Column<int>(type: "integer", nullable: false),
                    CreationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
                    CreatorId = table.Column<Guid>(type: "uuid", nullable: true),
                    HideLabel = table.Column<bool>(type: "boolean", nullable: false),
                    Label = table.Column<string>(type: "text", nullable: false),
                    LastModificationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
                    LastModifierId = table.Column<Guid>(type: "uuid", nullable: true),
                    NoColon = table.Column<bool>(type: "boolean", nullable: false),
                    Optional = table.Column<string>(type: "text", nullable: false),
                    OptionalHelp = table.Column<string>(type: "text", nullable: false),
                    OptionalHelpColor = table.Column<string>(type: "text", nullable: false),
                    StdViewContainerDictId = table.Column<Guid>(type: "uuid", nullable: true),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true),
                    Type = table.Column<string>(type: "text", nullable: false),
                    Unit = table.Column<string>(type: "text", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MainStdViewDict", x => x.Id);
                    table.ForeignKey(
                        name: "FK_MainStdViewDict_MainStdViewContainerDict_StdViewContainerDi~",
                        column: x => x.StdViewContainerDictId,
                        principalTable: "MainStdViewContainerDict",
                        principalColumn: "Id");
                });

            migrationBuilder.CreateTable(
                name: "MainStdTableRestrRule",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    StdTableColumnDictId = table.Column<Guid>(type: "uuid", nullable: false),
                    StdTableDictId = table.Column<Guid>(type: "uuid", nullable: false),
                    CreationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
                    CreatorId = table.Column<Guid>(type: "uuid", nullable: true),
                    LastModificationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
                    LastModifierId = table.Column<Guid>(type: "uuid", nullable: true),
                    RestrRuleValue = table.Column<string>(type: "text", nullable: true),
                    TableRestrRuleProvider = table.Column<int>(type: "integer", nullable: false),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MainStdTableRestrRule", x => x.Id);
                    table.ForeignKey(
                        name: "FK_MainStdTableRestrRule_MainStdTableColumnDict_StdTableColumn~",
                        column: x => x.StdTableColumnDictId,
                        principalTable: "MainStdTableColumnDict",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_MainStdTableRestrRule_MainStdTableDict_StdTableDictId",
                        column: x => x.StdTableDictId,
                        principalTable: "MainStdTableDict",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "MainStdViewValueDict",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    CreationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
                    CreatorId = table.Column<Guid>(type: "uuid", nullable: true),
                    LastModificationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
                    LastModifierId = table.Column<Guid>(type: "uuid", nullable: true),
                    Prefix = table.Column<string>(type: "text", nullable: false),
                    Size = table.Column<string>(type: "text", nullable: false),
                    StdViewDictId = table.Column<Guid>(type: "uuid", nullable: true),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true),
                    Tooltip = table.Column<string>(type: "text", nullable: false),
                    Unit = table.Column<string>(type: "text", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MainStdViewValueDict", x => x.Id);
                    table.ForeignKey(
                        name: "FK_MainStdViewValueDict_MainStdViewDict_StdViewDictId",
                        column: x => x.StdViewDictId,
                        principalTable: "MainStdViewDict",
                        principalColumn: "Id");
                });

            migrationBuilder.CreateIndex(
                name: "IX_MainStdApiDict_TopicDictId",
                table: "MainStdApiDict",
                column: "TopicDictId");

            migrationBuilder.CreateIndex(
                name: "IX_MainStdFormDict_ProductTopicId",
                table: "MainStdFormDict",
                column: "ProductTopicId");

            migrationBuilder.CreateIndex(
                name: "IX_MainStdTableColumnDict_StdTableDictId",
                table: "MainStdTableColumnDict",
                column: "StdTableDictId");

            migrationBuilder.CreateIndex(
                name: "IX_MainStdTableDict_StdApiConfigId",
                table: "MainStdTableDict",
                column: "StdApiConfigId");

            migrationBuilder.CreateIndex(
                name: "IX_MainStdTableDict_TopicDictId",
                table: "MainStdTableDict",
                column: "TopicDictId");

            migrationBuilder.CreateIndex(
                name: "IX_MainStdTableRestrRule_StdTableColumnDictId",
                table: "MainStdTableRestrRule",
                column: "StdTableColumnDictId");

            migrationBuilder.CreateIndex(
                name: "IX_MainStdTableRestrRule_StdTableDictId",
                table: "MainStdTableRestrRule",
                column: "StdTableDictId");

            migrationBuilder.CreateIndex(
                name: "IX_MainStdViewContainerDict_StdApiConfigId",
                table: "MainStdViewContainerDict",
                column: "StdApiConfigId");

            migrationBuilder.CreateIndex(
                name: "IX_MainStdViewContainerDict_TopicDictId",
                table: "MainStdViewContainerDict",
                column: "TopicDictId");

            migrationBuilder.CreateIndex(
                name: "IX_MainStdViewDict_StdViewContainerDictId",
                table: "MainStdViewDict",
                column: "StdViewContainerDictId");

            migrationBuilder.CreateIndex(
                name: "IX_MainStdViewValueDict_StdViewDictId",
                table: "MainStdViewValueDict",
                column: "StdViewDictId");
        }
    }
}
